Imports Microsoft.VisualBasic
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System
Imports System.Data
Imports GTSDAL
Imports GTSDALTableAdapters
Imports GTSSystem.BLL.IdGenerator

Namespace GTSSystem.BLL
    <System.ComponentModel.DataObject()> _
Public Class ContactInfo

        Private _contactInfoAdaptor As ContactInfoTableAdapter = Nothing

        Protected ReadOnly Property ContactInfoAdaptor() As ContactInfoTableAdapter
            Get
                If _contactInfoAdaptor Is Nothing Then
                    _contactInfoAdaptor = New ContactInfoTableAdapter
                End If
                Return _contactInfoAdaptor
            End Get
        End Property

        'place before lookup statements
        <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select, True)> _
        Public Function getContactInfo() As ContactInfoDataTable
            Try
                Return ContactInfoAdaptor.GetContactInfo
            Catch ex As Exception
                Throw
            End Try
        End Function

        <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select, True)> _
        Public Function getContactInfoByID(ByVal ContactInfoID As Integer) As ContactInfoDataTable
            Try
                Return ContactInfoAdaptor.GetContactInfoID(ContactInfoID)
            Catch ex As Exception
                Throw
            End Try
        End Function
        'place before insert statements
        <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Insert, True)> _
        Public Function addContactInfo(ByVal LocationID As Integer, _
                                        ByVal ContactName As String, ByVal Phone As String, ByVal Fax As String, _
                                        ByVal Email As String, ByVal StreetAddress As String) As Integer
            Dim ContactInfoPK As Integer
            Try
                ContactInfoPK = GetNextId("ContactInfo")
                ContactInfoAdaptor.Insert(ContactInfoPK, LocationID, ContactName, Phone, Fax, Email, StreetAddress)
                addContactInfo = ContactInfoPK
            Catch ex As Exception
                Throw
            End Try
        End Function
        'place before update statement
        <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Update, True)> _
        Public Sub updateContactInfo(ByVal ContactInfoID As Integer, ByVal LocationID As Integer, _
                                        ByVal ContactName As String, ByVal Phone As String, _
                                        ByVal Fax As String, ByVal Email As String, ByVal StreetAddress As String)
            Try
                ContactInfoAdaptor.Update(ContactInfoID, LocationID, ContactName, Phone, Fax, Email, StreetAddress)
            Catch ex As Exception
                Throw
            End Try
        End Sub
    End Class

End Namespace

